package cn.chia.back.action;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.chia.pojo.TblUser;
import cn.chia.service.IAdminService;

import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope(value="prototype")
public class AdminAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	private TblUser tuser;
	private IAdminService adminServiceImpl;
	
	public String login() throws Exception{
		TblUser loginUser = new TblUser();
		loginUser = adminServiceImpl.login(tuser);
		if(loginUser.getUserName()!=null && loginUser.getPassword().equals(tuser.getPassword())){
			ServletActionContext.getRequest().getSession().setAttribute("tuser", loginUser);
		}else{
			super.addActionError("验证错误");
			return "login";
		}
		return "adminIndex";
	}
	
	
	
	public TblUser getTuser() {
		return tuser;
	}
	public void setTuser(TblUser tuser) {
		this.tuser = tuser;
	}
	
	@Resource(name="adminServiceImpl")
	public void setAdminServiceImpl(IAdminService adminServiceImpl) {
		this.adminServiceImpl = adminServiceImpl;
	}
	
	

}
